package com.heima.admin.controller.v1;

import com.heima.admin.service.AdSensitiveService;
import com.heima.model.admin.dtos.SensitiveDTO;
import com.heima.model.admin.pojos.AdSensitive;
import com.heima.model.common.dtos.ResponseResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api/v1/sensitive")
@Api(value = "敏感词管理API",tags = "敏感词管理API")
@Slf4j
public class AdSensitiveController {
    @Autowired
    AdSensitiveService adSensitiveService;

    @ApiOperation(value = "敏感词查询")
    @PostMapping("/list")
    public ResponseResult selectByIdAndName(@RequestBody SensitiveDTO dto){
        return adSensitiveService.selectByIdAndName(dto);
    }
    @ApiOperation(value = "新增敏感词")
    @PostMapping("/save")
    public ResponseResult insert(@RequestBody AdSensitive adSensitive){
        return adSensitiveService.insert(adSensitive);
    }
    @ApiOperation(value = "修改敏感词")
    @PostMapping("/update")
    public ResponseResult update(@RequestBody AdSensitive adSensitive){
        return  adSensitiveService.update(adSensitive);
    }

    @ApiOperation(value = "根据删除敏感词")
    @DeleteMapping("/del/{id}")
    public ResponseResult delete(@PathVariable("id") Integer id){
        return  adSensitiveService.delete(id);
    }

    @ApiOperation(value = "查询敏感词内容列表")
    @PostMapping("/sensitives")
    public ResponseResult sensitives(){
        return adSensitiveService.selectAllSensitives();
    }
}
